<template>
  <div class="card">
    <div class="card_image">
      <img :src="data.cover_image" alt="Image" />
    </div>
    <div class="banner">
      <span class="banner-text">{{ data.tag }}</span>
    </div>
    <div class="card_content">
      <div class="card_content_title">{{ data.title }}</div>
      <div class="content">{{ data.content }}</div>
    </div>
    <div class="card_foot">
      <span>{{ data.author }}</span>
      <span class="text">|</span>
      <span> 发布于{{ data.created_at }}</span>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
});
</script>

<style scoped lang="scss">
.card {
  width: 100%;
  height: 400px;
  background: #3a3a3a;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  .card_image {
    width: 100%;
    height: 230px;
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      border-radius: 10px 10px 0 0;
      mask-image: linear-gradient(rgb(227, 227, 227), 80%, transparent);
    }
  }
  .banner {
    position: absolute;
    top: 3px;
    right: -95px;
    background: #000;
    color: #fff;
    padding: 15px;
    width: 100%;
    text-align: center;
    transform: rotate(45deg);
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 2px;
    overflow: hidden;
    .banner-text {
      display: inline-block;
      transition: opacity 0.5s ease, transform 0.5s ease;
      width: 100%;
      position: absolute;
      left: 13%;
      top: 50%;
      transform: translateY(-50%);
    }
  }
  .card_content {
    margin: 8px 16px 0 16px;
    .card_content_title {
      font-size: 22px;
      font-weight: 700;
      color: #fff;
      background: linear-gradient(
          90deg,
          var(--el-color-primary),
          var(--el-color-danger)
        )
        no-repeat left bottom;
      background-size: 0 3px;
      transition: background-size 0.8s;
      display: -webkit-box;
      -webkit-line-clamp: 2; //显示最大行数
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .content {
      font-size: 14px;
      line-height: 1.5;
      margin-top: 10px;
      color: #d8d8d8;
      display: -webkit-box;
      -webkit-line-clamp: 3; //显示最大行数
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  .card_foot {
    position: absolute;
    bottom: 8px;
    left: 16px;
    font-size: 12px;
    color: #7e7e7e;
    .text {
      padding: 0 5px;
    }
  }
}
</style>
